package com.car.service.Impl;

import com.car.entity.Image;
import com.car.entity.User;
import com.car.mapper.ImageMapper;
import com.car.mapper.UserMapper;
import com.car.service.UserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl implements UserService{
	
	@Autowired
	UserMapper userMapper;
	@Autowired
	ImageMapper imageMapper;

	@Override
	public int deleteByPrimaryKey(Integer userId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(User record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public User selectByPrimaryKey(Integer userId) {
		// TODO Auto-generated method stub
		return userMapper.selectByPrimaryKey(userId);
	}

	@Override
	public List<User> selectAll() {
		// TODO Auto-generated method stub
		return userMapper.selectAll();
	}

	@Override
	public int updateByPrimaryKey(User record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public User logins(String phone, String pwd) {
		// TODO Auto-generated method stub
		return userMapper.logins(phone, pwd);
	}

	@Override
	public int h5register(User user) {
		// TODO Auto-generated method stub
		return userMapper.h5register(user);
	}
/**
 * 修改用户信息
 */
	@Override
	public int updUserInfo(User user,Image image) {
		int nums =imageMapper.insert(image);
		if(nums>0){
			user.setIdCardImage(image.getPhotoId());
			nums = userMapper.updateByPrimaryKey(user);
		}
		// TODO Auto-generated method stub
		return nums>0?image.getPhotoId():0;
	}

@Override
public int updUserPwd(String userPwd, Integer userId) {
	// TODO Auto-generated method stub
	return userMapper.updUserPwd(userPwd, userId);
}

@Override
public int updUsersTojinji(String emergencyContacts, String contactNumber, int userId) {
	// TODO Auto-generated method stub
	return userMapper.updUsersTojinji(emergencyContacts, contactNumber, userId);
}

@Override
public int updUsersEmail(String email, Integer userId) {
	// TODO Auto-generated method stub
	return userMapper.updUsersEmail(email, userId);
}

@Override
public int updVip(Integer vipId, Integer userId) {
	// TODO Auto-generated method stub
	return userMapper.updVip(vipId, userId);
}

@Override
public User adminLogin(User user) {
	// TODO Auto-generated method stub
	return userMapper.adminLogin(user);
}

@Override
public List<User> selectUser() {
	// TODO Auto-generated method stub
	return userMapper.selectUser();
}
}